package com.ereport.controller.reportsController;


import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.ereport.dao.OpportunityDAO;
import com.ereport.entity.Executives;
import com.ereport.entity.Opportunity;

@Controller
@RequestMapping("/businessReport")
public class BusinessReportController {
	@RequestMapping("/open.do")
	public ModelAndView open(HttpServletRequest req,HttpSession session,ModelAndView model){
		Executives ex=(Executives)session.getAttribute("loginUser");
		if(ex==null){
			model.setViewName("/jsp/login.jsp");
			return model;
		}
		
		model.setViewName("/jsp/businessReport.jsp");
		
		return model;
	}
	@RequestMapping("/rfqOpen.do")
	public ModelAndView rfqOpen(HttpServletRequest req,HttpSession session,ModelAndView model){
		Executives ex=(Executives)session.getAttribute("loginUser");
		if(ex==null){
			model.setViewName("/jsp/login.jsp");
			return model;
		}
		OpportunityDAO opdao=new OpportunityDAO();
		List<Opportunity> oplist=new ArrayList<Opportunity>();
		try {
			oplist=opdao.getAll(ex.getId());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		model.setViewName("/jsp/rfqReport.jsp");
		model.addObject("oplist", oplist);
		return model;
	}
	@RequestMapping("/fnlOpen.do")
	public ModelAndView fnlOpen(HttpServletRequest req,HttpSession session,ModelAndView model){
		Executives ex=(Executives)session.getAttribute("loginUser");
		if(ex==null){
			model.setViewName("/jsp/login.jsp");
			return model;
		}
		OpportunityDAO opdao=new OpportunityDAO();
		List<Opportunity> oplist=new ArrayList<Opportunity>();
		try {
			oplist=opdao.getAll(ex.getId());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		model.setViewName("/jsp/rfqReport.jsp");
		model.addObject("oplist", oplist);
		return model;
	}
}
